package com.chart;

import com.chart.intercept.MyIntercept;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * Created by Administrator on 2017/8/8.
 */
@Configuration
public class InterceptConfig extends WebMvcConfigurerAdapter {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyIntercept()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }


    public static void main(String args[]) throws ExecutionException, InterruptedException {
        MyThread thread1 = new MyThread("A");
        MyThread thread2 = new MyThread("B");
        FutureTask<String> task1 = new FutureTask<String>(thread1);
        FutureTask<String> task2 = new FutureTask<String>(thread2);
        new Thread(task1).start();
        new Thread(task2).start();
        System.out.println(task1.get());
        System.out.println(task2.get());
    }
}

class MyThread implements Callable {
    private String name;

    public MyThread(String name) {
        this.name = name;
    }

    @Override
    public String call() throws Exception {
        for (int i = 0; i < 200; i++) {
            System.out.println("输出数字" + name + "--->：" + i);
        }
        return name + "线程执行结束";
    }
}